home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
jaz_clib.arc
/
JZFIND.DMO
< prev
next >
Wrap
Text File
|
1989-04-09
|
2KB
|
74 lines
/*
┌────────────────────────────────────────────────────────────────────────────┐
│ Title : JZFIND │
│ Purpose : Search through the entire disk, including all subdirectories │
│ for a file specified by the user. │
│ │
│ Usage: JZFIND <Filename> │
│ │
│ Written by Jack Zucker - 75766,1336 301-794-5950 on 1/28/86 │
└────────────────────────────────────────────────────────────────────────────┘
*/
#include <jzdirect.h>
char startdir[100];
char filename[100];
int FOUND = 0;
main(argc,argv)
int argc;
char **argv;
{
printf("\nJZFIND (C) JazSoft by Jack A. Zucker (301) 794-5950 | 75766,1336");
if (argc != 2) {
printf("\nUsage: JZFIND <Filename>\n");
exit(1);
}
strcpy(filename,strupr(*++argv)); /* get filename in global variable */
strcpy(startdir,""); /* start out with the root direct */
searchdir(startdir); /* start recursin' */
if ( ! FOUND ) printf("\n\nNo files were found matching %s",filename);
}
searchdir(fspec)
char *fspec;
#define SUBDIR 0x10 /* attribute for sub directory */
#define NORMAL 0x20 /* attribute for normal direct */
{
int werr;
TDIR wdir; /* hold the dos error number */
int w; /* work variable */
char path[100],temp[100]; /* work STRING variables */
strcpy(path,fspec); /* copy new file spec to work string */
strcat(path,"\\*.*"); /* put /*.* after it */
/* get subdirs and normal files */
werr = jzfndfst(path,NORMAL | SUBDIR,&wdir);
if (! werr ) /* we found at least one match */
do {
if (wdir.attr == SUBDIR && wdir.name[0] != '.') {
strcpy(path,fspec);
strcat(path,"\\");
strcat(path,wdir.name); /* append the new subdir */
searchdir(path); /* recurse against the new file spec */
}
if (jzwldcrd(wdir.name,filename)) { /* file matches user specs */
FOUND = 1; /* we found at least one match */
strcpy(temp,fspec); /* parse out the path */
printf("\n%s found in %s",wdir.name,*temp ? temp : "\\");
}
werr = jzfndnxt(&wdir); /* get the next directory item */
} while (! werr); /* loop until no more files */
}